<%@ CodePage="936" LCID="2052" %>
<%
Response.Buffer = EW_RESPONSE_BUFFER
%>
<!--#include file="lc_ewcfg8.asp"-->
<!--#include file="lc_donationinfo.asp"-->
<!--#include file="lc_userinfo.asp"-->
<!--#include file="lc_aspfn8.asp"-->
<!--#include file="md5.asp"-->
<!--#include file="lc_userfn8.asp"-->
<% Session.Timeout = 20 %>
<%
Response.Expires = 0
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "pragma", "no-cache"
Response.AddHeader "cache-control", "private, no-cache, no-store, must-revalidate"
%>
<%

' Define page object
Dim donation_edit
Set donation_edit = New cdonation_edit
Set Page = donation_edit

' Page init processing
Call donation_edit.Page_Init()

' Page main processing
Call donation_edit.Page_Main()
%>
<!--#include file="lc_header.asp"-->
<script type="text/javascript">
<!--
// Create page object
var donation_edit = new ew_Page("donation_edit");
// page properties
donation_edit.PageID = "edit"; // page ID
donation_edit.FormID = "fdonationedit"; // form ID
var EW_PAGE_ID = donation_edit.PageID; // for backward compatibility
// extend page with ValidateForm function
donation_edit.ValidateForm = function(fobj) {
	ew_PostAutoSuggest(fobj);
	if (!this.ValidateRequired)
		return true; // ignore validation
	if (fobj.a_confirm && fobj.a_confirm.value == "F")
		return true;
	var i, elm, aelm, infix;
	var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		elm = fobj.elements["x" + infix + "_company_id"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <%= ew_JsEncode2(donation.company_id.FldCaption) %>");
		elm = fobj.elements["x" + infix + "_company_id"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<%= ew_JsEncode2(donation.company_id.FldErrMsg) %>");
		elm = fobj.elements["x" + infix + "_donation_date"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <%= ew_JsEncode2(donation.donation_date.FldCaption) %>");
		elm = fobj.elements["x" + infix + "_donation_content"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <%= ew_JsEncode2(donation.donation_content.FldCaption) %>");
		elm = fobj.elements["x" + infix + "_donation_money"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <%= ew_JsEncode2(donation.donation_money.FldCaption) %>");
		elm = fobj.elements["x" + infix + "_donation_money"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<%= ew_JsEncode2(donation.donation_money.FldErrMsg) %>");
		elm = fobj.elements["x" + infix + "_donation_flower"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <%= ew_JsEncode2(donation.donation_flower.FldCaption) %>");
		elm = fobj.elements["x" + infix + "_donation_flower"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<%= ew_JsEncode2(donation.donation_flower.FldErrMsg) %>");
		elm = fobj.elements["x" + infix + "_donation_egg"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <%= ew_JsEncode2(donation.donation_egg.FldCaption) %>");
		elm = fobj.elements["x" + infix + "_donation_egg"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<%= ew_JsEncode2(donation.donation_egg.FldErrMsg) %>");
		// Call Form Custom Validate event
		if (!this.Form_CustomValidate(fobj)) return false;
	}
	return true;
}
// extend page with Form_CustomValidate function
donation_edit.Form_CustomValidate =  
 function(fobj) { // DO NOT CHANGE THIS LINE!
 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
donation_edit.SelectAllKey = function(elem) {
	ew_SelectAll(elem);
}
<% If EW_CLIENT_VALIDATE Then %>
donation_edit.ValidateRequired = true; // uses JavaScript validation
<% Else %>
donation_edit.ValidateRequired = false; // no JavaScript validation
<% End If %>
//-->
</script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->
</script>
<p><span class="aspmaker"><%= Language.Phrase("Edit") %>&nbsp;<%= Language.Phrase("TblTypeTABLE") %><%= donation.TableCaption %><br><br>
<a href="<%= donation.ReturnUrl %>"><%= Language.Phrase("GoBack") %></a></span></p>
<% If EW_DEBUG_ENABLED Then Response.Write donation_edit.DebugMsg %>
<% donation_edit.ShowMessage %>
<form name="fdonationedit" id="fdonationedit" action="<%= ew_CurrentPage %>" method="post" onsubmit="return donation_edit.ValidateForm(this);">
<p>
<input type="hidden" name="a_table" id="a_table" value="donation">
<input type="hidden" name="a_edit" id="a_edit" value="U">
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<% If donation.id.Visible Then ' id %>
	<tr<%= donation.id.RowAttributes %>>
		<td class="ewTableHeader"><%= donation.id.FldCaption %></td>
		<td<%= donation.id.CellAttributes %>><span id="el_id">
<div<%= donation.id.ViewAttributes %>><%= donation.id.EditValue %></div>
<input type="hidden" name="x_id" id="x_id" value="<%= Server.HTMLEncode(donation.id.CurrentValue&"") %>">
</span><%= donation.id.CustomMsg %></td>
	</tr>
<% End If %>
<% If donation.company_id.Visible Then ' company_id %>
	<tr<%= donation.company_id.RowAttributes %>>
		<td class="ewTableHeader"><%= donation.company_id.FldCaption %><%= Language.Phrase("FieldRequiredIndicator") %></td>
		<td<%= donation.company_id.CellAttributes %>><span id="el_company_id">
<input type="text" name="x_company_id" id="x_company_id" title="<%= donation.company_id.FldTitle %>" size="30" value="<%= donation.company_id.EditValue %>"<%= donation.company_id.EditAttributes %>>
</span><%= donation.company_id.CustomMsg %></td>
	</tr>
<% End If %>
<% If donation.donation_date.Visible Then ' donation_date %>
	<tr<%= donation.donation_date.RowAttributes %>>
		<td class="ewTableHeader"><%= donation.donation_date.FldCaption %><%= Language.Phrase("FieldRequiredIndicator") %></td>
		<td<%= donation.donation_date.CellAttributes %>><span id="el_donation_date">
<input type="text" name="x_donation_date" id="x_donation_date" title="<%= donation.donation_date.FldTitle %>" value="<%= donation.donation_date.EditValue %>"<%= donation.donation_date.EditAttributes %>>
</span><%= donation.donation_date.CustomMsg %></td>
	</tr>
<% End If %>
<% If donation.donation_content.Visible Then ' donation_content %>
	<tr<%= donation.donation_content.RowAttributes %>>
		<td class="ewTableHeader"><%= donation.donation_content.FldCaption %><%= Language.Phrase("FieldRequiredIndicator") %></td>
		<td<%= donation.donation_content.CellAttributes %>><span id="el_donation_content">
<textarea name="x_donation_content" id="x_donation_content" title="<%= donation.donation_content.FldTitle %>" cols="35" rows="4"<%= donation.donation_content.EditAttributes %>><%= donation.donation_content.EditValue %></textarea>
</span><%= donation.donation_content.CustomMsg %></td>
	</tr>
<% End If %>
<% If donation.donation_money.Visible Then ' donation_money %>
	<tr<%= donation.donation_money.RowAttributes %>>
		<td class="ewTableHeader"><%= donation.donation_money.FldCaption %><%= Language.Phrase("FieldRequiredIndicator") %></td>
		<td<%= donation.donation_money.CellAttributes %>><span id="el_donation_money">
<input type="text" name="x_donation_money" id="x_donation_money" title="<%= donation.donation_money.FldTitle %>" size="30" value="<%= donation.donation_money.EditValue %>"<%= donation.donation_money.EditAttributes %>>
</span><%= donation.donation_money.CustomMsg %></td>
	</tr>
<% End If %>
<% If donation.donation_flower.Visible Then ' donation_flower %>
	<tr<%= donation.donation_flower.RowAttributes %>>
		<td class="ewTableHeader"><%= donation.donation_flower.FldCaption %><%= Language.Phrase("FieldRequiredIndicator") %></td>
		<td<%= donation.donation_flower.CellAttributes %>><span id="el_donation_flower">
<input type="text" name="x_donation_flower" id="x_donation_flower" title="<%= donation.donation_flower.FldTitle %>" size="30" value="<%= donation.donation_flower.EditValue %>"<%= donation.donation_flower.EditAttributes %>>
</span><%= donation.donation_flower.CustomMsg %></td>
	</tr>
<% End If %>
<% If donation.donation_egg.Visible Then ' donation_egg %>
	<tr<%= donation.donation_egg.RowAttributes %>>
		<td class="ewTableHeader"><%= donation.donation_egg.FldCaption %><%= Language.Phrase("FieldRequiredIndicator") %></td>
		<td<%= donation.donation_egg.CellAttributes %>><span id="el_donation_egg">
<input type="text" name="x_donation_egg" id="x_donation_egg" title="<%= donation.donation_egg.FldTitle %>" size="30" value="<%= donation.donation_egg.EditValue %>"<%= donation.donation_egg.EditAttributes %>>
</span><%= donation.donation_egg.CustomMsg %></td>
	</tr>
<% End If %>
</table>
</div>
</td></tr></table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="<%= ew_BtnCaption(Language.Phrase("EditBtn")) %>">
</form>
<script language="JavaScript" type="text/javascript">
<!--
// Write your table-specific startup script here
// document.write("page loaded");
//-->
</script>
<!--#include file="lc_footer.asp"-->
<%

' Drop page object
Set donation_edit = Nothing
%>
<%

' -----------------------------------------------------------------
' Page Class
'
Class cdonation_edit

	' Page ID
	Public Property Get PageID()
		PageID = "edit"
	End Property

	' Table Name
	Public Property Get TableName()
		TableName = "donation"
	End Property

	' Page Object Name
	Public Property Get PageObjName()
		PageObjName = "donation_edit"
	End Property

	' Page Name
	Public Property Get PageName()
		PageName = ew_CurrentPage()
	End Property

	' Page Url
	Public Property Get PageUrl()
		PageUrl = ew_CurrentPage() & "?"
		If donation.UseTokenInUrl Then PageUrl = PageUrl & "t=" & donation.TableVar & "&" ' add page token
	End Property

	' Common urls
	Dim AddUrl
	Dim EditUrl
	Dim CopyUrl
	Dim DeleteUrl
	Dim ViewUrl
	Dim ListUrl

	' Export urls
	Dim ExportPrintUrl
	Dim ExportHtmlUrl
	Dim ExportExcelUrl
	Dim ExportWordUrl
	Dim ExportXmlUrl
	Dim ExportCsvUrl

	' Inline urls
	Dim InlineAddUrl
	Dim InlineCopyUrl
	Dim InlineEditUrl
	Dim GridAddUrl
	Dim GridEditUrl
	Dim MultiDeleteUrl
	Dim MultiUpdateUrl

	' Debug Message
	Dim m_DebugMsg

	Public Property Get DebugMsg()
		If m_DebugMsg <> "" Then
			DebugMsg = "<p>" & m_DebugMsg & "</p>"
		Else
			DebugMsg = ""
		End If
	End Property

	Public Property Let DebugMsg(v)
		If m_DebugMsg <> "" Then ' Append
			m_DebugMsg = m_DebugMsg & "<br>" & v
		Else
			m_DebugMsg = v
		End If
	End Property

	' Message
	Public Property Get Message()
		Message = Session(EW_SESSION_MESSAGE)
	End Property

	Public Property Let Message(v)
		If Session(EW_SESSION_MESSAGE) <> "" Then ' Append
			Session(EW_SESSION_MESSAGE) = Session(EW_SESSION_MESSAGE) & "<br>" & v
		Else
			Session(EW_SESSION_MESSAGE) = v
		End If
	End Property

	' Show Message
	Public Sub ShowMessage()
		Dim sMessage
		sMessage = Message
		Call Message_Showing(sMessage)
		If sMessage <> "" Then Response.Write "<p><span class=""ewMessage"">" & sMessage & "</span></p>"
		Session(EW_SESSION_MESSAGE) = "" ' Clear message in Session
	End Sub

	' -----------------------
	'  Validate Page request
	'
	Public Function IsPageRequest()
		If donation.UseTokenInUrl Then
			IsPageRequest = False
			If Not (ObjForm Is Nothing) Then
				IsPageRequest = (donation.TableVar = ObjForm.GetValue("t"))
			End If
			If Request.QueryString("t").Count > 0 Then
				IsPageRequest = (donation.TableVar = Request.QueryString("t"))
			End If
		Else
			IsPageRequest = True
		End If
	End Function

	' -----------------------------------------------------------------
	'  Class initialize
	'  - init objects
	'  - open ADO connection
	'
	Private Sub Class_Initialize()
		StartTimer = Timer ' Init start time

		' Initialize language object
		Set Language = New cLanguage

		' Initialize table object
		Set donation = New cdonation

		' Initialize urls
		' Initialize other table object

		Set user = New cuser

		' Initialize form object
		Set ObjForm = Nothing

		' Intialize page id (for backward compatibility)
		EW_PAGE_ID = "edit"

		' Initialize table name (for backward compatibility)
		EW_TABLE_NAME = "donation"

		' Open connection to the database
		Call ew_Connect()
	End Sub

	' -----------------------------------------------------------------
	'  Subroutine Page_Init
	'  - called before page main
	'  - check Security
	'  - set up response header
	'  - call page load events
	'
	Sub Page_Init()
		Set Security = New cAdvancedSecurity
		If Not Security.IsLoggedIn() Then Call Security.AutoLogin()
		If Not Security.IsLoggedIn() Then
			Call Security.SaveLastUrl()
			Call Page_Terminate("lc_login.asp")
		End If

	' Create form object
	Set ObjForm = New cFormObj

		' Global page loading event (in userfn7.asp)
		Call Page_Loading()

		' Page load event, used in current page
		Call Page_Load()
	End Sub

	' -----------------------------------------------------------------
	'  Class terminate
	'  - clean up page object
	'
	Private Sub Class_Terminate()
		Call Page_Terminate("")
	End Sub

	' -----------------------------------------------------------------
	'  Subroutine Page_Terminate
	'  - called when exit page
	'  - clean up ADO connection and objects
	'  - if url specified, redirect to url
	'
	Sub Page_Terminate(url)

		' Page unload event, used in current page
		Call Page_Unload()

		' Global page unloaded event (in userfn60.asp)
		Call Page_Unloaded()
		If Not (Conn Is Nothing) Then Conn.Close ' Close Connection
		Set Conn = Nothing
		Set Security = Nothing
		Set donation = Nothing
		Set ObjForm = Nothing

		' Go to url if specified
		Dim sRedirectUrl
		sReDirectUrl = url
		Call Page_Redirecting(sReDirectUrl)
		If sReDirectUrl <> "" Then
			If Response.Buffer Then Response.Clear
			Response.Redirect sReDirectUrl
		End If
	End Sub

	'
	'  Subroutine Page_Terminate (End)
	' ----------------------------------------

	Dim sDbMasterFilter, sDbDetailFilter

	' -----------------------------------------------------------------
	' Page main processing
	'
	Sub Page_Main()

		' Load key from QueryString
		If Request.QueryString("id").Count > 0 Then
			donation.id.QueryStringValue = Request.QueryString("id")
		End If
		If ObjForm.GetValue("a_edit")&"" <> "" Then
			donation.CurrentAction = ObjForm.GetValue("a_edit") ' Get action code
			Call LoadFormValues() ' Get form values

			' Validate Form
			If Not ValidateForm() Then
				donation.CurrentAction = "" ' Form error, reset action
				Message = gsFormError
				donation.EventCancelled = True ' Event cancelled
				Call LoadRow() ' Restore row
				Call RestoreFormValues() ' Restore form values if validate failed
			End If
		Else
			donation.CurrentAction = "I" ' Default action is display
		End If

		' Check if valid key
		If donation.id.CurrentValue = "" Then Call Page_Terminate("lc_donationlist.asp") ' Invalid key, return to list
		Select Case donation.CurrentAction
			Case "I" ' Get a record to display
				If Not LoadRow() Then ' Load Record based on key
					Message = Language.Phrase("NoRecord") ' No record found
					Call Page_Terminate("lc_donationlist.asp") ' No matching record, return to list
				End If
			Case "U" ' Update
				donation.SendEmail = True ' Send email on update success
				If EditRow() Then ' Update Record based on key
					Message = Language.Phrase("UpdateSuccess") ' Update success
					Dim sReturnUrl
					sReturnUrl = donation.ReturnUrl
					If ew_GetPageName(sReturnUrl) = "lc_donationview.asp" Then sReturnUrl = donation.ViewUrl ' View paging, return to view page with keyurl directly
					Call Page_Terminate(sReturnUrl) ' Return to caller
				Else
					donation.EventCancelled = True ' Event cancelled
					Call LoadRow() ' Restore row
					Call RestoreFormValues() ' Restore form values if update failed
				End If
		End Select

		' Render the record
		donation.RowType = EW_ROWTYPE_EDIT ' Render as edit

		' Render row
		Call RenderRow()
	End Sub

	' -----------------------------------------------------------------
	' Function Get upload files
	'
	Function GetUploadFiles()

		' Get upload data
	End Function

	' -----------------------------------------------------------------
	' Load form values
	'
	Function LoadFormValues()

		' Load values from form
		donation.id.FormValue = ObjForm.GetValue("x_id")
		donation.id.OldValue = ObjForm.GetValue("o_id")
		donation.company_id.FormValue = ObjForm.GetValue("x_company_id")
		donation.company_id.OldValue = ObjForm.GetValue("o_company_id")
		donation.donation_date.FormValue = ObjForm.GetValue("x_donation_date")
		donation.donation_date.CurrentValue = ew_UnFormatDateTime(donation.donation_date.CurrentValue, 8)
		donation.donation_date.OldValue = ObjForm.GetValue("o_donation_date")
		donation.donation_content.FormValue = ObjForm.GetValue("x_donation_content")
		donation.donation_content.OldValue = ObjForm.GetValue("o_donation_content")
		donation.donation_money.FormValue = ObjForm.GetValue("x_donation_money")
		donation.donation_money.OldValue = ObjForm.GetValue("o_donation_money")
		donation.donation_flower.FormValue = ObjForm.GetValue("x_donation_flower")
		donation.donation_flower.OldValue = ObjForm.GetValue("o_donation_flower")
		donation.donation_egg.FormValue = ObjForm.GetValue("x_donation_egg")
		donation.donation_egg.OldValue = ObjForm.GetValue("o_donation_egg")
	End Function

	' -----------------------------------------------------------------
	' Restore form values
	'
	Function RestoreFormValues()
		donation.id.CurrentValue = donation.id.FormValue
		donation.company_id.CurrentValue = donation.company_id.FormValue
		donation.donation_date.CurrentValue = donation.donation_date.FormValue
		donation.donation_date.CurrentValue = ew_UnFormatDateTime(donation.donation_date.CurrentValue, 8)
		donation.donation_content.CurrentValue = donation.donation_content.FormValue
		donation.donation_money.CurrentValue = donation.donation_money.FormValue
		donation.donation_flower.CurrentValue = donation.donation_flower.FormValue
		donation.donation_egg.CurrentValue = donation.donation_egg.FormValue
	End Function

	' -----------------------------------------------------------------
	' Load row based on key values
	'
	Function LoadRow()
		Dim RsRow, sSql, sFilter
		sFilter = donation.KeyFilter

		' Call Row Selecting event
		Call donation.Row_Selecting(sFilter)

		' Load sql based on filter
		donation.CurrentFilter = sFilter
		sSql = donation.SQL
		If EW_DEBUG_ENABLED Then DebugMsg = "LoadRow: " & sSql ' Show SQL for debugging
		Set RsRow = ew_LoadRow(sSql)
		If RsRow.Eof Then
			LoadRow = False
		Else
			LoadRow = True
			RsRow.MoveFirst
			Call LoadRowValues(RsRow) ' Load row values

			' Call Row Selected event
			Call donation.Row_Selected(RsRow)
		End If
		RsRow.Close
		Set RsRow = Nothing
	End Function

	' -----------------------------------------------------------------
	' Load row values from recordset
	'
	Sub LoadRowValues(RsRow)
		Dim sDetailFilter
		donation.id.DbValue = RsRow("id")
		donation.company_id.DbValue = RsRow("company_id")
		donation.donation_date.DbValue = RsRow("donation_date")
		donation.donation_content.DbValue = RsRow("donation_content")
		donation.donation_money.DbValue = RsRow("donation_money")
		donation.donation_flower.DbValue = RsRow("donation_flower")
		donation.donation_egg.DbValue = RsRow("donation_egg")
	End Sub

	' -----------------------------------------------------------------
	' Render row values based on field settings
	'
	Sub RenderRow()

		' Initialize urls
		' Call Row Rendering event

		Call donation.Row_Rendering()

		' ---------------------------------------
		'  Common render codes for all row types
		' ---------------------------------------
		' id

		donation.id.CellCssStyle = ""
		donation.id.CellCssClass = ""

		' company_id
		donation.company_id.CellCssStyle = ""
		donation.company_id.CellCssClass = ""

		' donation_date
		donation.donation_date.CellCssStyle = ""
		donation.donation_date.CellCssClass = ""

		' donation_content
		donation.donation_content.CellCssStyle = ""
		donation.donation_content.CellCssClass = ""

		' donation_money
		donation.donation_money.CellCssStyle = ""
		donation.donation_money.CellCssClass = ""

		' donation_flower
		donation.donation_flower.CellCssStyle = ""
		donation.donation_flower.CellCssClass = ""

		' donation_egg
		donation.donation_egg.CellCssStyle = ""
		donation.donation_egg.CellCssClass = ""

		' -----------
		'  View  Row
		' -----------

		If donation.RowType = EW_ROWTYPE_VIEW Then ' View row

			' id
			donation.id.ViewValue = donation.id.CurrentValue
			donation.id.CssStyle = ""
			donation.id.CssClass = ""
			donation.id.ViewCustomAttributes = ""

			' company_id
			donation.company_id.ViewValue = donation.company_id.CurrentValue
			donation.company_id.CssStyle = ""
			donation.company_id.CssClass = ""
			donation.company_id.ViewCustomAttributes = ""

			' donation_date
			donation.donation_date.ViewValue = donation.donation_date.CurrentValue
			donation.donation_date.CssStyle = ""
			donation.donation_date.CssClass = ""
			donation.donation_date.ViewCustomAttributes = ""

			' donation_content
			donation.donation_content.ViewValue = donation.donation_content.CurrentValue
			donation.donation_content.CssStyle = ""
			donation.donation_content.CssClass = ""
			donation.donation_content.ViewCustomAttributes = ""

			' donation_money
			donation.donation_money.ViewValue = donation.donation_money.CurrentValue
			donation.donation_money.CssStyle = ""
			donation.donation_money.CssClass = ""
			donation.donation_money.ViewCustomAttributes = ""

			' donation_flower
			donation.donation_flower.ViewValue = donation.donation_flower.CurrentValue
			donation.donation_flower.CssStyle = ""
			donation.donation_flower.CssClass = ""
			donation.donation_flower.ViewCustomAttributes = ""

			' donation_egg
			donation.donation_egg.ViewValue = donation.donation_egg.CurrentValue
			donation.donation_egg.CssStyle = ""
			donation.donation_egg.CssClass = ""
			donation.donation_egg.ViewCustomAttributes = ""

			' View refer script
			' id

			donation.id.HrefValue = ""
			donation.id.TooltipValue = ""

			' company_id
			donation.company_id.HrefValue = ""
			donation.company_id.TooltipValue = ""

			' donation_date
			donation.donation_date.HrefValue = ""
			donation.donation_date.TooltipValue = ""

			' donation_content
			donation.donation_content.HrefValue = ""
			donation.donation_content.TooltipValue = ""

			' donation_money
			donation.donation_money.HrefValue = ""
			donation.donation_money.TooltipValue = ""

			' donation_flower
			donation.donation_flower.HrefValue = ""
			donation.donation_flower.TooltipValue = ""

			' donation_egg
			donation.donation_egg.HrefValue = ""
			donation.donation_egg.TooltipValue = ""

		' ----------
		'  Edit Row
		' ----------

		ElseIf donation.RowType = EW_ROWTYPE_EDIT Then ' Edit row

			' id
			donation.id.EditCustomAttributes = ""
			donation.id.EditValue = donation.id.CurrentValue
			donation.id.CssStyle = ""
			donation.id.CssClass = ""
			donation.id.ViewCustomAttributes = ""

			' company_id
			donation.company_id.EditCustomAttributes = ""
			donation.company_id.EditValue = ew_HtmlEncode(donation.company_id.CurrentValue)

			' donation_date
			donation.donation_date.EditCustomAttributes = ""
			donation.donation_date.EditValue = donation.donation_date.CurrentValue

			' donation_content
			donation.donation_content.EditCustomAttributes = ""
			donation.donation_content.EditValue = ew_HtmlEncode(donation.donation_content.CurrentValue)

			' donation_money
			donation.donation_money.EditCustomAttributes = ""
			donation.donation_money.EditValue = ew_HtmlEncode(donation.donation_money.CurrentValue)

			' donation_flower
			donation.donation_flower.EditCustomAttributes = ""
			donation.donation_flower.EditValue = ew_HtmlEncode(donation.donation_flower.CurrentValue)

			' donation_egg
			donation.donation_egg.EditCustomAttributes = ""
			donation.donation_egg.EditValue = ew_HtmlEncode(donation.donation_egg.CurrentValue)

			' Edit refer script
			' id

			donation.id.HrefValue = ""

			' company_id
			donation.company_id.HrefValue = ""

			' donation_date
			donation.donation_date.HrefValue = ""

			' donation_content
			donation.donation_content.HrefValue = ""

			' donation_money
			donation.donation_money.HrefValue = ""

			' donation_flower
			donation.donation_flower.HrefValue = ""

			' donation_egg
			donation.donation_egg.HrefValue = ""
		End If

		' Call Row Rendered event
		Call donation.Row_Rendered()
	End Sub

	' -----------------------------------------------------------------
	' Validate form
	'
	Function ValidateForm()

		' Initialize
		gsFormError = ""

		' Check if validation required
		If Not EW_SERVER_VALIDATE Then
			ValidateForm = (gsFormError = "")
			Exit Function
		End If
		If Not IsNull(donation.company_id.FormValue) And donation.company_id.FormValue&"" = "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & Language.Phrase("EnterRequiredField") & " - " & donation.company_id.FldCaption
		End If
		If Not ew_CheckInteger(donation.company_id.FormValue) Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & donation.company_id.FldErrMsg
		End If
		If Not IsNull(donation.donation_date.FormValue) And donation.donation_date.FormValue&"" = "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & Language.Phrase("EnterRequiredField") & " - " & donation.donation_date.FldCaption
		End If
		If Not IsNull(donation.donation_content.FormValue) And donation.donation_content.FormValue&"" = "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & Language.Phrase("EnterRequiredField") & " - " & donation.donation_content.FldCaption
		End If
		If Not IsNull(donation.donation_money.FormValue) And donation.donation_money.FormValue&"" = "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & Language.Phrase("EnterRequiredField") & " - " & donation.donation_money.FldCaption
		End If
		If Not ew_CheckInteger(donation.donation_money.FormValue) Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & donation.donation_money.FldErrMsg
		End If
		If Not IsNull(donation.donation_flower.FormValue) And donation.donation_flower.FormValue&"" = "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & Language.Phrase("EnterRequiredField") & " - " & donation.donation_flower.FldCaption
		End If
		If Not ew_CheckInteger(donation.donation_flower.FormValue) Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & donation.donation_flower.FldErrMsg
		End If
		If Not IsNull(donation.donation_egg.FormValue) And donation.donation_egg.FormValue&"" = "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & Language.Phrase("EnterRequiredField") & " - " & donation.donation_egg.FldCaption
		End If
		If Not ew_CheckInteger(donation.donation_egg.FormValue) Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & donation.donation_egg.FldErrMsg
		End If

		' Return validate result
		ValidateForm = (gsFormError = "")

		' Call Form Custom Validate event
		Dim sFormCustomError
		sFormCustomError = ""
		ValidateForm = ValidateForm And Form_CustomValidate(sFormCustomError)
		If sFormCustomError <> "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & sFormCustomError
		End If
	End Function

	' -----------------------------------------------------------------
	' Update record based on key values
	'
	Function EditRow()
		If Not EW_DEBUG_ENABLED Then On Error Resume Next
		Dim Rs, sSql, sFilter
		Dim RsChk, sSqlChk, sFilterChk
		Dim bUpdateRow
		Dim RsOld, RsNew
		Dim sIdxErrMsg

		' Clear any previous errors
		Err.Clear
		sFilter = donation.KeyFilter
		donation.CurrentFilter  = sFilter
		sSql = donation.SQL
		Set Rs = Server.CreateObject("ADODB.Recordset")
		Rs.CursorLocation = EW_CURSORLOCATION
		Rs.Open sSql, Conn, 1, 2
		If Err.Number <> 0 Then
			Message = Err.Description
			Rs.Close
			Set Rs = Nothing
			EditRow = False
			Exit Function
		End If

		' Clone old recordset object
		Set RsOld = ew_CloneRs(Rs)
		If Rs.Eof Then
			EditRow = False ' Update Failed
		Else

			' Field company_id
			Call donation.company_id.SetDbValue(Rs, donation.company_id.CurrentValue, 0, False)

			' Field donation_date
			Call donation.donation_date.SetDbValue(Rs, donation.donation_date.CurrentValue, Now, False)

			' Field donation_content
			Call donation.donation_content.SetDbValue(Rs, donation.donation_content.CurrentValue, "", False)

			' Field donation_money
			Call donation.donation_money.SetDbValue(Rs, donation.donation_money.CurrentValue, 0, False)

			' Field donation_flower
			Call donation.donation_flower.SetDbValue(Rs, donation.donation_flower.CurrentValue, 0, False)

			' Field donation_egg
			Call donation.donation_egg.SetDbValue(Rs, donation.donation_egg.CurrentValue, 0, False)

			' Check recordset update error
			If Err.Number <> 0 Then
				Message = Err.Description
				Rs.Close
				Set Rs = Nothing
				EditRow = False
				Exit Function
			End If

			' Call Row Updating event
			bUpdateRow = donation.Row_Updating(RsOld, Rs)
			If bUpdateRow Then

				' Clone new recordset object
				Set RsNew = ew_CloneRs(Rs)
				Rs.Update
				If Err.Number <> 0 Then
					Message = Err.Description
					EditRow = False
				Else
					EditRow = True
				End If
			Else
				Rs.CancelUpdate
				If donation.CancelMessage <> "" Then
					Message = donation.CancelMessage
					donation.CancelMessage = ""
				Else
					Message = Language.Phrase("UpdateCancelled")
				End If
				EditRow = False
			End If
		End If

		' Call Row Updated event
		If EditRow Then
			Call donation.Row_Updated(RsOld, RsNew)
		End If
		Rs.Close
		Set Rs = Nothing
		If IsObject(RsOld) Then
			RsOld.Close
			Set RsOld = Nothing
		End If
		If IsObject(RsNew) Then
			RsNew.Close
			Set RsNew = Nothing
		End If
	End Function

	' Page Load event
	Sub Page_Load()

		'Response.Write "Page Load"
	End Sub

	' Page Unload event
	Sub Page_Unload()

		'Response.Write "Page Unload"
	End Sub

	' Page Redirecting event
	Sub Page_Redirecting(url)

		'url = newurl
	End Sub

	' Message Showing event
	Sub Message_Showing(msg)

		'msg = newmsg
	End Sub

	' Form Custom Validate event
	Function Form_CustomValidate(CustomError)

		'Return error message in CustomError
		Form_CustomValidate = True
	End Function
End Class
%>
